package com.onepiece.shipelves.common.ticker;

import com.onepiece.shipelves.common.utils.JsonUtil;

/**
 * 交易所交易对模型
 *
 * @author guoyanjiang
 * @date 2019-01-28
 */
public class ExchangePairDTO extends BaseExchangePair {

    public String symbolShow;
    public ExchangeCurrency exchangeCurrency;
    public int abnormalStatus;


    public ExchangePairDTO() {
    }

    public ExchangePairDTO(String exchangeKey, String pair, BaseTickerPair baseTickerPair, String coinKey, String currencyShow, ExchangeCurrency exchangeCurrency) {
        super(exchangeKey, coinKey, pair, baseTickerPair, currencyShow);
        this.exchangeCurrency = exchangeCurrency;
    }

    public ExchangePairDTO(String exchangeKey, String pair, String coinKey, String symbolShow, String currencyShow) {
        super(exchangeKey, coinKey, pair, currencyShow);
        this.symbolShow = symbolShow;
        //this.exchangeCurrency = new ExchangeCurrency(exchangeKey, provideCoinCurrencyUnitInPair());
        this.exchangeCurrency = new ExchangeCurrency(provideTickerExchangeKey(), provideCoinCurrencyUnitInPair());
    }

    public ExchangePairDTO(String exchangeKey, BaseTickerPair baseTickerPair, String coinKey, String symbolShow, String currencyShow) {
        super(exchangeKey, coinKey, baseTickerPair.providePairStr(), currencyShow);
        this.symbolShow = symbolShow;
        //this.exchangeCurrency = new ExchangeCurrency(exchangeKey, provideCoinCurrencyUnitInPair());
        this.exchangeCurrency = new ExchangeCurrency(provideTickerExchangeKey(), provideCoinCurrencyUnitInPair());
    }

    public ExchangePairDTO(String exchangeKey, BaseTickerPair baseTickerPair, String coinKey, String symbolShow, String currencyShow, Integer tradeType) {
        super(exchangeKey, coinKey, baseTickerPair.providePairStr(), currencyShow, tradeType);
        this.symbolShow = symbolShow;
        //this.exchangeCurrency = new ExchangeCurrency(exchangeKey, provideCoinCurrencyUnitInPair());
        this.exchangeCurrency = new ExchangeCurrency(provideTickerExchangeKey(), provideCoinCurrencyUnitInPair());
    }

    public int getAbnormalStatus() {
        return abnormalStatus;
    }

    public void setAbnormalStatus(int abnormalStatus) {
        this.abnormalStatus = abnormalStatus;
    }

    public String providePairShow() {
        return symbolShow + "_" + super.getCurrencyShow();
    }

    public String getSymbolShow() {
        return symbolShow;
    }

    public void setSymbolShow(String symbolShow) {
        this.symbolShow = symbolShow;
    }


    public void setExchangeCurrency(ExchangeCurrency exchangeCurrency) {
        this.exchangeCurrency = exchangeCurrency;
    }

    public ExchangeCurrency getExchangeCurrency() {
        return exchangeCurrency;
    }

    //todo：是否需要替代成pairshow
    public String provideShowPair() {
        return String.format("%s/%s", symbolShow, super.getCurrencyShow()).toUpperCase();
    }

    @Override
    public String toString() {
        return JsonUtil.toJson(this);
    }

}
